#include "StdAfx.h"
#include "Tools.h"

using namespace System;
using namespace WMFInterface;


Guid Tools::GuidFromPGUID(GUID& gid)
{
	array<byte>^ guidBytes = gcnew array<byte>(sizeof(gid));
	byte* p = reinterpret_cast<byte*>(&gid);
	for (int i = 0; i < sizeof(gid); ++i, ++p)
		guidBytes[i] = *p;
	return Guid(guidBytes);
}

StreamType Tools::StreamTypeFromGuid(GUID& gid)
{
	if (::memcmp(&gid, &WMMEDIATYPE_Video, sizeof(GUID)) == 0)
		return StreamType::Video;
	if (::memcmp(&gid, &WMMEDIATYPE_Audio, sizeof(GUID)) == 0)
		return StreamType::Audio;
	if (::memcmp(&gid, &WMMEDIATYPE_Script, sizeof(GUID)) == 0)
		return StreamType::Script;
	if (::memcmp(&gid, &WMMEDIATYPE_FileTransfer, sizeof(GUID)) == 0)
		return StreamType::FileTransfer;
	if (::memcmp(&gid, &WMMEDIATYPE_Image, sizeof(GUID)) == 0)
		return StreamType::Image;
	if (::memcmp(&gid, &WMMEDIATYPE_Text, sizeof(GUID)) == 0)
		return StreamType::Text;
	return StreamType::Unknown;
}
